﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;

namespace Quanlybanhang
{
    public partial class ThemchubanForm : Office2007Form
    {
        public ThemchubanForm()
        {
            InitializeComponent();
        }

        private void btnXoatrang_Click(object sender, EventArgs e)
        {
            txtTen.Text = "";
            txtDiachi.Text = "";
            txtDienthoai.Text = "";
            txtSono.Text = "";
        }

        private void btnThemmoi_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtSono.Text == "") txtSono.Text = "0";
                SqlCommand sqlComm = new SqlCommand();
                sqlComm = MainForm.con.CreateCommand();
                sqlComm.CommandText = @"INSERT INTO CHUHANG VALUES('" + txtTen.Text + "', '" + txtDiachi.Text + "', '" + txtDienthoai.Text + "', " + txtSono.Text + ", 2)";
                sqlComm.ExecuteNonQuery();
                MessageBox.Show("Thêm mới thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thêm mới không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
